//
//  LFTMCTitleMaker.m
//  lofter-mvpcourse-ios
//
//  Created by Thomas Quan on 2017/5/3.
//  Copyright © 2017年 undefined-zola. All rights reserved.
//

#import "LFTMCTitleMaker.h"

@implementation LFTMCTitleMaker

+ (NSString *)titleMaker: (NSString *)title {
    //    title = @"一二三四五六七八九十一二三四五六(222)"; //测试
    // 匹配找出群成员数量
//    NSString *count;
//    NSError *error = NULL;
//    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(\\d+)" options:NSRegularExpressionCaseInsensitive error:&error];
//    NSTextCheckingResult *result = [regex firstMatchInString:title options:0 range:NSMakeRange(0, [title length])];
//    if (result) {
//        count = [title substringWithRange:result.range];
//    } else {
//        count = @"";
//    }
    
    // 大于15字的部分不显示，用 "..." 代替
    NSUInteger upLimit = 15;
    if ([title length] <= upLimit) {
        return title;
    }
    
    title = [NSString stringWithFormat:@"%@...", [title substringToIndex:upLimit]];
    
    return title;
}

@end
